<template>
	<view class="">
		<view class="page" v-if="type == 1">
			<view class="body">
				<textarea placeholder="请输入公告内容" v-model="text" maxlength="-1">
			</textarea>
			</view>
			<view class="btn" style="margin-top: 50px;">
				确定
			</view>
		</view>
		<view class="page" v-if="type == 2">
			<view class="body">
				<textarea placeholder="请输入公告内容" v-model="text2" maxlength="-1">
			</textarea>
			</view>
			<view class="btn" style="margin-top: 50px;">
				确定
			</view>
		</view>
		<view class="page" v-if="type == 3">
			<view class="body">
				<view class="body_cont justify-content-sp" v-for="(item,index) in dataList" :key="item.index"
					:style="item.id==0?'border:none':''">
					<view class="">
						{{item.text}}
					</view>
					<view class="" style="margin-top: -10rpx;">
						<switch :checked="item.checked" style="transform:scale(0.6)" @change="change(item.id)" />
					</view>
				</view>
			</view>
			<view class="btn" style="margin-top: 50px;" @click="addPay">
				新增
			</view>
			<uni-popup ref="popup" type="bottom" border-radius="10px 10px 0 0">
				<view class="popup_bj">
					<view class="">
						<section>支付类型</section>
					</view>
					<view class="popup_bj_se">
						<uni-data-select v-model="value" :localdata="payway" @change="changed"></uni-data-select>
					</view>
					<view class="popup_bj_thr justify-content-sp">
						<view class="popup_bj_btn" @click="toPath(1)">
							取消
						</view>
						<view class="popup_bj_btn" @click="toPath(2)">
							确定
						</view>
					</view>
				</view>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				text: '', //滚动公告
				text2: '', //弹窗公告
				type: '',
				dataList: [{
						id: 0,
						text: "支付宝1【h5】",
						checked: true
					},
					{
						id: 1,
						text: "支付宝2【h5】",
						checked: false
					},
					{
						id: 2,
						text: "微信支付1【h5】",
						checked: true
					},
					{
						id: 3,
						text: "微信支付2【h5】",
						checked: false
					}
				],
				value: '',
				payway: [{
						value: 0,
						text: "微信"
					},
					{
						value: 1,
						text: "支付宝"
					}
				],
				pay_way: ''
			}
		},
		onLoad(e) {
			this.type = e.type;
			if (e.type == 2) {
				uni.setNavigationBarTitle({
					title: '滚动公告'
				})
			} else if (e.type == 3) {
				uni.setNavigationBarTitle({
					title: '支付配置'
				})
			}
		},
		methods: {
			change(id) {
				this.dataList[id].checked = !this.dataList[id].checked;
			},
			changed(e) {
				this.pay_way = e
			},
			addPay() {
				this.$refs.popup.open('center')
			},
			toPath(e) {
				if (e == 1) {
					this.$refs.popup.close('center')
				} else {
					this.$refs.popup.close('center')
					uni.navigateTo({
						url: '/pages/disposition/index?type=' + this.pay_way
					})
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.page {
		.body {
			width: 630rpx;

			.body_input {
				height: 300px;
			}

			.body_cont {
				border-top: 1rpx solid #b2b2b2;
				padding: 15rpx 0;
			}
		}

		.popup_bj {
			background-color: white;
			width: 510rpx;
			padding: 30rpx;
			border-radius: 30rpx;

			.popup_bj_se {
				padding: 30rpx 0;
			}

			.popup_bj_thr {
				margin-top: 10px;

				.popup_bj_btn {
					width: 50%;
					text-align: center;
				}
			}
		}
	}
</style>